<?php if (!defined('THINK_PATH')) exit(); /*a:3:{s:76:"D:\phpstudy_pro\WWW\xqyw\public/../application/system\view\article\edit.html";i:1715413820;s:65:"D:\phpstudy_pro\WWW\xqyw\application\system\view\public\head.html";i:1715411275;s:67:"D:\phpstudy_pro\WWW\xqyw\application\system\view\public\footer.html";i:1704857607;}*/ ?>
<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>后台管理系统</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="icon" href="/static/system/images/favicon.ico">
	<link rel="stylesheet" href="/static/system/css/themes/default.css" media="all">
	<link rel="stylesheet" href="/static/system/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
	<link rel="stylesheet" href="/static/system/lib/layui-v2.9.9/css/layui.css" media="all">
	<link rel="stylesheet" href="/static/system/css/public.css" media="all">
	<link rel="stylesheet" href="/static/system/css/layuimini.css?v=2.0.4.2" media="all">

	<script src="/static/system/lib/layui-v2.9.9/layui.js" charset="utf-8"></script>
	<script src="/static/system/js/lay-config.js?v=2.0.0" charset="utf-8"></script>
	<script>
        // 是否开启刷新记忆tab功能
        // var is_remember = false;
    </script>
	<!--[if lt IE 9]>
		<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
		<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
		<![endif]-->
	<style id="layuimini-bg-color">
	</style>
</head>
<style>
    body {
        background-color: #ffffff;
    }
</style>

<body>
    <div class="layui-form layuimini-form">
        <input type="hidden" name="id" value="<?php echo $article['id']; ?>"> 
        <div class="layui-form-item">
            <label class="layui-form-label required">文章标题</label>
            <div class="layui-input-inline">
                <select name="pid" lay-verify="required" lay-reqtext="请选择文章所属分类">
                  <option value="">请选择文章所属分类</option>
                  <?php if(is_array($category) || $category instanceof \think\Collection || $category instanceof \think\Paginator): $i = 0; $__LIST__ = $category;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                  <option value="<?php echo $vo['id']; ?>" <?php echo $article['pid']==$vo['id']?'selected':''; ?>><?php echo $vo['name']; ?></option>
                  <?php endforeach; endif; else: echo "" ;endif; ?>
                </select>
            </div>
          </div>
  
          <div class="layui-form-item">
            <label class="layui-form-label required">文章标题</label>
            <div class="layui-input-inline">
              <input type="text" name="title" lay-verify="required" lay-reqtext="文章标题不能为空" placeholder="请输入文章名称" value="<?php echo $article['title']; ?>" class="layui-input" autocomplete="off">
            </div>
          </div>
  
          <div class="layui-form-item">
            <label class="layui-form-label">文章副标题</label>
            <div class="layui-input-inline">
              <input type="text" name="desc"  placeholder="请输入文章副标题" value="<?php echo $article['desc']; ?>" class="layui-input" autocomplete="off">
            </div>
          </div>
  
          <div class="layui-form-item">
            <label class="layui-form-label">文章内容</label>
            <div class="layui-input-block">
              <div id="content" style="margin: 50px 0 50px 0">
                <?php echo $article['content']; ?>
              </div>
            </div>
          </div>
  
          <div class="layui-form-item">
            <label class="layui-form-label">文章状态</label>
            <div class="layui-input-inline">
                  <input type="checkbox" name="status" value="1" lay-skin="switch" lay-text="显示|隐藏" <?php echo $article['status']==1?'checked':''; ?>>
            </div>
          </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                <a href="javascript:;"  class="layui-btn layui-btn-primary layui-border" lay-active="closePage">关闭</a>
            </div>
        </div>
    </div>
    </div>
    <script>
        layui.use(['form','util','wangEditor'], function () {
            var form = layui.form,
                layer = layui.layer,
                util = layui.util,
                wangEditor = layui.wangEditor,
                $ = layui.$;

            //创建一个编辑器
            var editor = new wangEditor('#content');
            editor.customConfig.uploadImgServer = "<?php echo url('UpFiles/editUpload'); ?>";
            editor.customConfig.uploadFileName = 'image';
            editor.customConfig.pasteFilterStyle = false;
            editor.customConfig.uploadImgMaxLength = 5;
            editor.customConfig.uploadImgHooks = {
                // 上传超时
                timeout: function (xhr, editor) {
                    layer.msg('上传超时！')
                },
                // 如果服务器端返回的不是 {errno:0, data: [...]} 这种格式，可使用该配置
                customInsert: function (insertImg, result, editor) {
                  if (result.code == 0) {
                        var url = result.data.src;
                        insertImg(url);
                    } else {
                        layer.msg(result.msg);
                    }
                }
            };
            editor.customConfig.customAlert = function (info) {
                layer.msg(info);
            };
            editor.create();

            //监听提交
            form.on('submit(saveBtn)', function (data) {
                data.field.content = editor.txt.html();
                if(data.field.status == undefined) {
                    data.field.status = 0;
                }
                // 提交到方法 默认为本身
                $.post("<?php echo url('edit'); ?>",data.field,function(res){
                    if(res.code > 0){
                      layer.msg(res.msg,{time:1800,icon:1});
                      // 关闭弹出层
                      setTimeout(() => {
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.location.reload();//刷新父页面，注意一定要在关闭当前iframe层之前执行刷新
                        parent.layer.close(iframeIndex);
                      }, 1800);
                    }else{
                        layer.msg(res.msg,{time:1800,icon:2});
                    }
                });
            });
            
            util.event('lay-active',{
                closePage: function() {
                    var iframeIndex = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(iframeIndex);
                }
            });

        });
    </script>
    <script>
    layui.use(['jquery', 'layer', 'miniAdmin'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            miniAdmin = layui.miniAdmin,
            iniUrl = {};
        var options = {
            iniUrl: "<?php echo url('index/getSystemInit'); ?>", // 初始化接口
            clearUrl: "clear", // 缓存清理接口
            urlHashLocation: true, // 是否打开hash定位
            bgColorDefault: false, // 主题默认配置
            multiModule: true, // 是否开启多模块
            menuChildOpen: false, // 是否默认展开菜单
            loadingTime: 0, // 初始化加载时间
            pageAnim: true, // iframe窗口动画
            maxTabNum: 20, // 最大的tab打开数量
        };
        miniAdmin.render(options);
        $('.login-out').on("click", function () {
            $.post("<?php echo url('Login/outlogin'); ?>",{},function(res) {
                layer.msg('退出登录成功', function () {
                    window.location = 'Login/index';
                });
            })

        });
    });
</script>
<script>
    //预览大小根据原图的大小决定弹窗的大小
    function previewImg(obj) {
        var img = new Image();
        img.src = obj.src;
        var height = img.height + 50; //获取图片高度
        var width = img.width; //获取图片宽度
        var imgHtml = "<img src='" + obj.src + "' width='100%' height='100%'/>";
        //弹出层
        layer.open({
            type: 1,
            shade: 0.8,
            offset: 'auto',
            // area: [height + 'px', width + 'px'],
            area: ['800px', '600px'],
            shadeClose: true,
            scrollbar: false,
            title: '', //不显示标题
            content: imgHtml, //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
            cancel: function () {
                //layer.msg('捕获就是从页面已经存在的元素上，包裹layer的结构', { time: 5000, icon: 6 });
            }
        });
    }
</script>
</body>

</html>